// +----------------------------------------------------------------------
// | Copyright (c) 2015-2025 http://www.hdphp.cn All rights reserved.
// | Licensed ( http://www.hdphp.cn/licenses/ )
// | Author: Jack <sophia2152@qq.com>
// | 官方网址: http://www.hdphp.cn
// | 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用。
// | 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
// +----------------------------------------------------------------------
import { defHttp } from '@/utils/http/axios';
import {
  CategoryParams,
  CategoryPageParams,
  CategoryPageListGetResultModel,
  FilePageParams,
  FilePageListGetResultModel,
  FileNameParams,
  FileParams,
} from './model/uploadPicturesModel';

enum Api {
  // 附件分类--列表
  CategoryList = '/file/category/list',
  // 添加分类
  CreateCategory = '/file/category/create',
  // 编辑分类
  UpdateCategory = '/file/category/update',
  // 删除分类
  DeleteCategory = '/file/category/delete',

  // 附件列表
  FileList = '/file/list',
  // 修改附件名称
  UpdateFileName = '/file/file/update',
  // 删除附件
  DeleteFile = '/file/file/delete',
  // 移动图片
  MoveToFile = '/file/file/do_move',
}

/**
 * 附件分类列表
 * @param params
 * @returns
 */
export const getCategoryList = (params?: CategoryPageParams) =>
  defHttp.get<CategoryPageListGetResultModel>({
    url: Api.CategoryList,
    params,
  });

/**
 * 添加分类
 * @param params
 * @returns
 */
export const createCategory = (params: CategoryParams) =>
  defHttp.post({ url: Api.CreateCategory, params });

/**
 * 编辑分类
 * @param params
 * @returns
 */
export const updateCategory = (id: number | string, params: CategoryParams) =>
  defHttp.put({ url: `${Api.UpdateCategory}/${id}`, params });

/**
 * 删除分类
 * @param params
 * @returns
 */
export const deleteCategory = (id: number | string) =>
  defHttp.delete({ url: `${Api.DeleteCategory}/${id}` });

/**
 * 附件列表
 * @param params
 * @returns
 */
export const getFileList = (params: FilePageParams) =>
  defHttp.get<FilePageListGetResultModel>({
    url: Api.FileList,
    params,
  });

/**
 * 修改附件名称
 * @param params
 * @returns
 */
export const updateFileName = (id: number | string, params: FileNameParams) =>
  defHttp.put({ url: `${Api.UpdateFileName}/${id}`, params });

/**
 * 移动图片
 * @param params
 * @returns
 */
export const moveToFile = (params: FileParams) => defHttp.put({ url: Api.MoveToFile, params });

/**
 * 删除附件
 * @param params
 * @returns
 */
export const deleteFile = (params: FileParams) => defHttp.post({ url: Api.DeleteFile, params });
